<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="../../plugins/element-ui/index.css" />
		<link rel="stylesheet" href="../../styles/common.css" />
		<link rel="stylesheet" href="../../styles/page.css" />
		<style>
			#member-app .notAdmin::after {
				border: 0 !important;

			}
			 * {margin:0;padding:0} 
			.custom-button {
			  margin-left: 10px; /* 调整按钮与<h3>标签之间的水平间距 */
			  float: right;
			 
			}
			 .text {
			    font-size: 14px;
			  }
			
			  .item {
			    margin-bottom: 18px;
			  }
			
			  .clearfix:before,
			  .clearfix:after {
			    display: table;
			    content: "";
			  }
			  .clearfix:after {
			    clear: both
			  }
			
			  .box-card {
			    width: 480px;
			  }
			
			
		</style>
	</head>
	<body>
		<div class="dashboard-container" id="member-app">
			<div class="container">
		<div class="block">
		  <el-timeline>
		    <el-timeline-item v-for="(item,index) in data" :timestamp="item.createtime" placement="top" v-if="item.status==='0' ">
		     <el-card>
				 <div>
		        
		           <h3 ><span style="font-size: 10px; ">航班号:</span> {{item.cfno}}</h3>
				   
				   <p style="color: darkgray;">&nbsp;&nbsp;---By Manager: <span style="color: black">{{item.manager}}</span></p>
				   
		           <el-button style="float: right;" class="custom-button" type="success" icon="el-icon-check" circle @click="open(item,index)"></el-button>
		        <div style="float: left; margin-top: 20px;">
		         <p ><i class="el-icon-refresh-left"></i><span style="font-size: 15px; color: darkgray;">&nbsp;&nbsp;起飞时间: </span> {{item.startTime}} <span style="font-size: 15px; color: darkgray;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;到达时间: </span>{{item.endTime}}</p>
		         <i class="el-icon-message-solid"></i><span style="font-size: 15px; color: darkgray;">&nbsp;&nbsp;Reason:</span>
				 <p style="margin-left:22px;">{{item.text}}</p>
				 </div>
				 </div>
		       </el-card>
			   
			  <!-- <el-card class="box-card">
			     <div slot="header" class="clearfix">
			       <span>航班号: {{item.cfno}}</span>
			       <el-button class="custom-button" type="success" icon="el-icon-check" circle @click="open(item,index)"></el-button>
			     </div>
			     <div v-for="o in 4" :key="o" class="text item">
			       {{'列表内容 ' + o }}
			     </div>
			   </el-card> -->
		    </el-timeline-item>
		   
		  </el-timeline>
		</div>
		


			</div>
		</div>
		<!-- 开发环境版本，包含了有帮助的命令行警告 -->
		<script src="../../plugins/vue/vue.js"></script>
		<!-- 引入组件库 -->
		<script src="../../plugins/element-ui/index.js"></script>
		<!-- 引入axios -->
		<script src="../../plugins/axios/axios.min.js"></script>
		<script src="../../js/request.js"></script>
		<script src="../../api/member.js"></script>
		<script>
			new Vue({
				el: '#member-app',
				data() {
					return {

						data: []

					}
				},

				created() {
					
					 this.init()

				},

				methods: {
					open(item,index){
						
						
						var dateObj = new Date(item.startTime)
						var year = dateObj.getFullYear();
						var month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
						var day = ("0" + dateObj.getDate()).slice(-2);
						var hours = ("0" + dateObj.getHours()).slice(-2);
						var minutes = ("0" + dateObj.getMinutes()).slice(-2);
						var seconds = ("0" + dateObj.getSeconds()).slice(-2);
						
						 datetime = year + month + day + hours + minutes + seconds;
						 item.startTime  =datetime
						 
						 var dateObj = new Date(item.endTime)
						 var year = dateObj.getFullYear();
						 var month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
						 var day = ("0" + dateObj.getDate()).slice(-2);
						 var hours = ("0" + dateObj.getHours()).slice(-2);
						 var minutes = ("0" + dateObj.getMinutes()).slice(-2);
						 var seconds = ("0" + dateObj.getSeconds()).slice(-2);
						 
						  datetime = year + month + day + hours + minutes + seconds;
						  item.endTime  =datetime
						
						item.status='1';
						
						console.log(item)
						editFlight(item).then(res => {
							if (res.code === 200) {
								this.$message.success('审核成功')
								
							} else {
								this.$message.error(res.msg || '审核失败，请重试')
							}
						}).catch(err => {
							this.$message.error('审核请求出错了：' + err)
						})
					},
					
						async init() {
							
							await queryView().then(res => {
								console.log(res)
								if (String(res.code) === '200') {
									for (var i = 0; i < res.data.length; i++) {
										var timeString = res.data[i].startTime;
										var year = timeString.substring(0, 4);
										var month = timeString.substring(4, 6);
										var day = timeString.substring(6, 8);
										var hour = timeString.substring(8, 10);
										var minute = timeString.substring(10, 12);
										var second = timeString.substring(12, 14);
					
										var formatStartTime = year + "-" + month + "-" + day + " " + hour + ":" +
											minute +
											":" + second;
										res.data[i].startTime = formatStartTime
					
										var timeString = res.data[i].endTime;
										var year = timeString.substring(0, 4);
										var month = timeString.substring(4, 6);
										var day = timeString.substring(6, 8);
										var hour = timeString.substring(8, 10);
										var minute = timeString.substring(10, 12);
										var second = timeString.substring(12, 14);
					
										var formatEndTime = year + "-" + month + "-" + day + " " + hour + ":" +
											minute +
											":" + second;
										res.data[i].endTime = formatEndTime
										
										var timeString = res.data[i].createtime
										var year = timeString.substring(0, 4);
										var month = timeString.substring(4, 6);
										var day = timeString.substring(6, 8);
										var hour = timeString.substring(8, 10);
										var minute = timeString.substring(10, 12);
										var second = timeString.substring(12, 14);
															
										var formatEndTime = year + "-" + month + "-" + day + " " + hour + ":" +
											minute +
											":" + second;
										res.data[i].createtime = formatEndTime
										
									}
					
									
									this.data = res.data || []
									console.log(this.data)
									
								}
							})
						},
						
					
						
					
						
					





				}
			})
		</script>
	</body>
</html>
